package com.example.mybatisdemo.mapper;

import com.example.mybatisdemo.model.ArticleInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ArticleInfoMapper {
    @Select("select * from articleinfo where id = #{articleId}")
    ArticleInfo selectById1(Integer articleId);

    @Select("select * from articleinfo where id = #{articleId}")
    List<ArticleInfo> selectById2(Integer articleId);

    /*
     * @author: 江传文
     * @date: 2024/3/17 20:42
       多表查询
     * @return: com.example.mybatisdemo.model.ArticleInfo
            **/
    @Select("select ta.*,tb.username,tb.age from articleinfo as ta " +
            "left join userinfo as tb " +
            "on ta.uid = tb.id where ta.id = 1")
    ArticleInfo selectById3();
}
